<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <title>月度意见分值设置</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/iconfont.css')}}">
   {{-- <link rel="stylesheet" href="{{asset('/css/system/common.css')}}">--}}
    <link rel="stylesheet" href="/css/system/common.css?v=201812121">
    <link rel="stylesheet" href="/css/system/rewards-setting.css?v=20181214021">
    @include('sysadmin.head')
</head>
<style>
    .opinion-set{
        background-color: #ececec;
        height:30px;
        width:100%;
        text-align: center;
    }
    .op-name{
        text-align: center;
        border: none;
        background: none;
        width:60px;
        font-size: 16px;
    }
</style>
<body ontouchstart>
<div class="mian-container">
    <div class="weui-flex" style="line-height: 40px;">
        <div class="weui-flex__item" style="text-align: center">
            <input class='op-name'  type="text" name="opinion-name" value="{{$feedback->name}}" data-values="{{$feedback->id}}"/>
            <i class="icon iconfont icon-xiala"></i>
        </div>
    </div>
    <form class="rewards-setting" onsubmit="return false;">
        <div class="rewards-list">
            <div class="weui-flex">
                <div class="weui-flex__item">
                    <p>等级名称</p>
                </div>
                <div class="weui-flex__item">
                    <p>对应分值</p>
                </div>
            </div>
            @foreach(unserialize($feedback->detail) as $k=>$v)
                <div class="weui-flex">
                    <div class="weui-flex__item">
                        <input type="text" class="" name="opname[]" value="{{$k}}">
                    </div>
                    <div class="weui-flex__item">
                        <input type="text" class="input-score" name="opvalue[]" value="{{$v}}" data-values="{{$v}}">
                    </div>
                </div>
            @endforeach
        </div>
        {!! csrf_field() !!}
        <a href="javascript:;" class="btn-submit weui-btn weui-btn_color">完成</a>
    </form>
    <!-- 隐藏考核按钮部分-->
    @include('sysadmin.admin-caidan')
</div>
<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>
<script>
    $(document).ready(function () {
        $('.kaohe-item').click(function(){
            $('.show-hidden').toggle();
        });
        $('.admin-item').click(function(){
            $('.front-show-hidden').toggle();
        });

        var rearray = {!! $names !!};
        $(".op-name").select({
            title: "选择意见名称",
            items: rearray,
            onClose:function(){
                var fid = $('input[name=opinion-name]').attr('data-values');
                window.location.href='/sysadmin/feedback/feedback?feedid='+fid;
            }
        });


        $(".input-score").select({
            title: "选择分值",
            items: [{
                'title':'-5',
                'value':'-5',
            },{
                'title':'-4',
                'value':'-4',
            },{
                'title':'-3',
                'value':'-3',
            },{
                'title':'-2',
                'value':'-2',
            },{
                'title':'-1',
                'value':'-1',
            },{
                'title':'0',
                'value':'0',
            },{
                'title':'1',
                'value':'1',
            },{
                'title':'2',
                'value':'2',
            },{
                'title':'3',
                'value':'3',
            },{
                'title':'4',
                'value':'4',
            },{
                'title':'5',
                'value':'5',
            }],
            onClose: function(data) {
                $(".mian-container").css({"position":"initial","height":"auto"});
            },
            onOpen: function(data) {
                $(".mian-container").css({'position':'fixed',"width":"100%"});
            }
        });



        //ajax表单提交
        $('.btn-submit').click(function(){
            var token = $('input[name=_token]').val();
            var feedid = $('input[name=opinion-name]').attr('data-values');
            var ids = [];
            $('input[name="opname[]"]').each(function () {
                if($(this).val().length > 7){
                    $.toast('名称太长',"text");
                    return false;
                }
                ids.push($(this).val());
            });
            var pids = [];
            $('input[name="opvalue[]"]').each(function () {
                pids.push($(this).attr('data-values'));
            });
            $.ajax({
                'url': '/sysadmin/feedback/modify-feedback?_token='+token+'&feedid='+feedid,
                'type': 'POST',
                'data': {'feed_name':JSON.stringify(ids),'feed_score':JSON.stringify(pids)},
                error: function (request) {
                    $.toast('网络错误',"text");
                },
                success: function (data) {
                    if (data.status == 'success') {
                        $.toast("操作成功");
                        window.location.href='/sysadmin/permission/index';
                    } else {
                        $.toast(data.msg,"text");
                    }
                },
            });
        })
    })
</script>
</body>
</html>